//
//  SSPresentTopView.swift
//  拾舍清洁
//
//  Created by sky.wei on 2023/2/24.
//

import UIKit

class SSPresentTopView: UIView {
    
    var type:String = "1"
    var imageV = UIImageView()
    
    
    ///init方法，纯代码创建时调用
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    
    //init方法，通过xib创建时调用
    required init?(coder: NSCoder) {
        super.init(coder: coder)
        setupUI()
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        setupUI()
    }
    
    func setupUI() {
        let imageV = UIImageView()
        imageV.image = UIImage(named: "normal_clean_image")
        imageV.frame = self.bounds
        addSubview(imageV)
        self.imageV = imageV
        
        let closeBtn = UIButton()
        closeBtn.setBackgroundImage(UIImage(named: "close_cirle"), for: .normal)
        closeBtn.setBackgroundImage(UIImage(named: "close_cirle"), for: .highlighted)
        closeBtn.frame = CGRect(x: frame.width - 40 - 16, y: 14, width: 40, height: 40)
        addSubview(closeBtn)
        
        closeBtn.addTarget(self, action: #selector(closeAction), for: .touchUpInside)
            
    }
    
    func setType(type:String) {
        if type == "1" {
            imageV.image = UIImage(named: "normal_clean_image")
        }else if (type == "2"){
            imageV.image = UIImage(named: "checkout_image")
        }else if (type == "3"){
            imageV.image = UIImage(named: "deep_clean_image")
        }else if (type == "4"){
            imageV.image = UIImage(named: "steam_carpet_image")
        }
    }

    @objc func closeAction(){
        UIViewController.current().dismiss(animated: true)
    }
}
